import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import Framework.*;



public class win_Browser extends pnl_Ancestor implements ActionListener{

	btn_TopButtons b_TopButtons 	= new btn_TopButtons("Music");
	
	
	// Setting up bottom menu
	btn_BottomButtons 	b_BottomButtons = new btn_BottomButtons(6);
	btn_Ancestor 			btn_btm_Playlist = new btn_Ancestor("Playlist");
	btn_Ancestor 			btn_btm_Movies = new btn_Ancestor("Movies");
	
	
	// In Window buttons. Text only atm TODO Images on buttons!
	btn_Ancestor btn_Pause = new btn_Ancestor("II");
	btn_Ancestor btn_Play = new btn_Ancestor("|>");
	btn_Ancestor btn_Next = new btn_Ancestor("|>>");
	btn_Ancestor btn_Prev = new btn_Ancestor("<<|");
	btn_Ancestor btn_Stop = new btn_Ancestor("| |");
	btn_Ancestor btn_Mute = new btn_Ancestor("Mute.");
	
	public win_Browser(){
		super(); // Remember to always call super on JPanel_Anc constructors!
		
		// Adding Top buttons
		this.add(b_TopButtons);
		
		// Adding bottom buttons
		b_BottomButtons.add(btn_btm_Playlist, 1);
		b_BottomButtons.add(btn_btm_Movies, 5);
		
		// Setting coordinates and size of Buttons. Using b_BottomButtons Size as a guideline.
		// Commented code is exmaples of how to do it with int values.
			//btn_Pause.setBounds(50,400,50,50);
			//btn_Pause.setVisible(false);
			//btn_Play.setBounds(50,400,50,50);
			//btn_Next.setBounds(110,400,50,50);
			//btn_Prev.setBounds(170,400,50,50);
			//btn_Stop.setBounds(230,400,50,50);
			//btn_Mute.setBounds(280,400,50,50);
		Rectangle lrect_ButtonSize = b_BottomButtons.getComponent(0).getBounds();
		
		lrect_ButtonSize.y = 600 - lrect_ButtonSize.height * 2;
		lrect_ButtonSize.x = 0;
		
		btn_Pause.setBounds(lrect_ButtonSize);
		btn_Play.setBounds(lrect_ButtonSize);
		btn_Pause.setVisible(false);
		lrect_ButtonSize.x += lrect_ButtonSize.width;
		
		btn_Next.setBounds(lrect_ButtonSize);
		lrect_ButtonSize.x += lrect_ButtonSize.width;
		btn_Prev.setBounds(lrect_ButtonSize);
		lrect_ButtonSize.x += lrect_ButtonSize.width;
		btn_Stop.setBounds(lrect_ButtonSize);
		lrect_ButtonSize.x += lrect_ButtonSize.width;
		btn_Mute.setBounds(lrect_ButtonSize);
			
		// Adding buttons to event handler.
		btn_Play.addActionListener(this);
		btn_Pause.addActionListener(this);
		btn_btm_Playlist.addActionListener(this);
		btn_btm_Movies.addActionListener(this);
		// Adding content
		this.add(btn_Pause);
		this.add(btn_Play);
		this.add(btn_Next);
		this.add(btn_Prev);
		this.add(btn_Stop);
		this.add(btn_Mute);
		
		this.add(b_BottomButtons);
		
		this.validate();
	}	
	
	public void actionPerformed(ActionEvent e) {
		
		Object actionSource = (btn_Ancestor) e.getSource();
		
		if (actionSource.equals(btn_Play)){
			btn_Play.setVisible(false);
			btn_Pause.setVisible(true);
		} else if (actionSource.equals(btn_Pause)){
			btn_Play.setVisible(true);
			btn_Pause.setVisible(false);
		} else if (actionSource.equals(btn_btm_Playlist)){
			enterSubMenu(TeamRocket.w_Playlist);
		}  else if (actionSource.equals(btn_btm_Movies)){
			this.getRootPane().setContentPane(TeamRocket.w_MoviePlayer);
		}
		
	}
}
